package 链表;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/9/7 22:38
 */
public class lc2两数相加 {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        ListNode sentinel = new ListNode(), cur  = sentinel;
        int x  = 0;
        while(l1 != null || l2 != null || x !=0){
            if(l1 != null){
                x += l1.val;
                l1 = l1.next;
            }
            if(l2 != null){
                x += l2.val;
                l2 = l2.next;
            }
            cur.next = new ListNode(x % 10);
            cur = cur.next;
            x /=10;
        }
        return sentinel.next;
    }


    public static void main(String[] args) {
        System.out.println(String.valueOf(Long.MAX_VALUE).length());
    }


    class ListNode{
        int val;
        ListNode next;


        public ListNode (int val){
            this.val = val;
        }
        public ListNode (){}

    }
}
